<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link href="css/bootstrap.css" rel="stylesheet">
    <style>
        form {
            margin: 0;
            padding: 0;
            text-align: center;
        }

        #title > h1 {
            color: #aa0719;
            margin-left: 300px;
        }
    </style>
</head>
<body>
<div id="title">
    <h1>修改商家</h1>
</div>
<hr>
<form class="form-inline">
    <div class="form-group">
        <label for="sname">商家名称</label>
        <input type="text" class="form-control" id="sname" name="sname" placeholder="请输入商家名称"><br>
        <div id="div1" hidden><span id="checkSname"></span></div>
        </span>
        <br>
        <label for="saddress">商家地址</label>
        <input class="form-control" type="text" id="saddress" name="saddress" placeholder="请输入商家地址"><br/><br>
        <label for="phone">联系方式</label>
        <input class="form-control" type="text" id="phone" name="phone" placeholder="请输入联系方式"><br/><br>
        <label for="stype">商家类别</label><select id="stype" name="stype" class="form-control">
        <option value="0">请选择商家类别</option>
        <option value="1">中餐</option>
        <option value="2">西餐</option>
    </select><br><br>
        <button class="btn btn-info" type="button" id="addbtn" name="addbtn">保存</button>
    </div>
</form>
</body>
<script src="js/jquery-3.2.1.js"></script>
<script src="js/layer/layer.js"></script>
<script>
    var url = location.href;
    var params = url.split('?')[1];
    var sid = params.split('=')[1];
    $(function () {
        $.get('query_store_idByManager',{sid:sid},function (data) {
            if(data.code==200){
                $('#sname').val(data.result.sname);
                $('#suser').val(data.result.suser);
                $('#spwd').val(data.result.spwd);
                $('#saddress').val(data.result.saddress);
                $('#phone').val(data.result.phone);
                $('#stype').val(data.result.stype).attr('check','check');
            }
        },'json')

        $('#addbtn').click(function () {
            $.post('update_store',{
                sid:sid,
                sname:$('#sname').val(),
                saddress:$('#saddress').val(),
                phone:$('#phone').val(),
                stype:$('#stype').val()
            },function (data) {
                if(data.code==200){
                    layer.msg(data.msg, {icon: 1, time: 2000}, function () {
                        location.href = "Managermain.html";
                    })
                }else{
                    layer.msg(data.msg)
                }
            },'json')
        })
    })

</script>
</html>